/**
 * 
 */
package org.lanqiao.netctoss.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.lanqiao.netctoss.dao.TariffDao;
import org.lanqiao.netctoss.entity.Tariff;
import org.lanqiao.netctoss.service.TariffService;
import org.lanqiao.netctoss.util.GetSession;

/**
 * @author Administrator
 *
 */
public class TariffServiceImpl implements TariffService {

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.lanqiao.netctoss.service.TariffService#insTariff(org.lanqiao.netctoss
	 * .entity.Tariff)
	 */
	@Override
	public int insTariff(Tariff tariff) {
		// TODO Auto-generated method stub
		int i =0;
		SqlSession session = GetSession.getSession();
		TariffDao tariffDao = session.getMapper(TariffDao.class);
		i = tariffDao.insertTariff(tariff);
		session.commit();
		GetSession.close();
		return i;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.lanqiao.netctoss.service.TariffService#delTariff(org.lanqiao.netctoss
	 * .entity.Tariff)
	 */
	@Override
	public int delTariff(Tariff tariff) {
		// TODO Auto-generated method stub
		int i =0;
		SqlSession session = GetSession.getSession();
		TariffDao tariffDao = session.getMapper(TariffDao.class);
		i = tariffDao.deleteTariff(tariff);
		session.commit();
		GetSession.close();
		return i;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.lanqiao.netctoss.service.TariffService#updTariff(org.lanqiao.netctoss
	 * .entity.Tariff)
	 */
	@Override
	public int updTariff(Tariff tariff) {
		// TODO Auto-generated method stub
		int i =0;
		SqlSession session = GetSession.getSession();
		TariffDao tariffDao = session.getMapper(TariffDao.class);
		i = tariffDao.updateTariff(tariff);
		session.commit();
		GetSession.close();
		return i;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.lanqiao.netctoss.service.TariffService#updateTarStateByno(org.lanqiao
	 * .netctoss.entity.Tariff)
	 */
	@Override
	public int updateTarStateByno(Tariff tariff) {
		// TODO Auto-generated method stub
		int i =0;
		SqlSession session = GetSession.getSession();
		TariffDao tariffDao = session.getMapper(TariffDao.class);
		i = tariffDao.updateTarStateByno(tariff);
		session.commit();
		GetSession.close();
		return i;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.lanqiao.netctoss.service.TariffService#selTariff()
	 */
	@Override
	public List<Tariff> selTariff() {
		// TODO Auto-generated method stub
		List<Tariff> lt = new ArrayList<Tariff>();
		SqlSession session = GetSession.getSession();
		TariffDao tariffDao = session.getMapper(TariffDao.class);
		lt = tariffDao.selectTariff();
		session.commit();
		GetSession.close();
		return lt;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.lanqiao.netctoss.service.TariffService#selectTariffByno(org.lanqiao
	 * .netctoss.entity.Tariff)
	 */
	@Override
	public List<Tariff> selectTariffByno(Tariff tariff) {
		// TODO Auto-generated method stub
		List<Tariff> lt = new ArrayList<Tariff>();
		SqlSession session = GetSession.getSession();
		TariffDao tariffDao = session.getMapper(TariffDao.class);
		lt = tariffDao.selectTariffByno(tariff);
		session.commit();
		GetSession.close();
		return lt;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.lanqiao.netctoss.service.TariffService#selectTariffName()
	 */
	@Override
	public List<Tariff> selectTariffName() {
		// TODO Auto-generated method stub
		SqlSession session = GetSession.getSession();
		TariffDao tariffDao = session.getMapper(TariffDao.class);
		List<Tariff> lt  = tariffDao.selectTariffName();
		session.commit();
		GetSession.close();
		return lt;
	}

}
